import {defineStore} from "pinia";
import {darkTheme, useOsTheme} from "naive-ui";

export const useThemeStore = defineStore("theme", {
    state: () => ({
        themeMode: (localStorage.getItem('__theme_mode__') || useOsTheme().value) === 'dark' ? 'dark' : null,
        layoutHeaderHeight: 64,
        layoutFooterHeight: 64,
    }),
    getters: {
        isDark: (state) => state.themeMode === 'dark',
        theme: (state) => state.themeMode === 'dark' ? darkTheme : null

    },
    actions: {
        changeTheme() {
            this.themeMode = this.themeMode ? null : 'dark'
            localStorage.setItem('__theme_mode__', this.themeMode)
        }
    }
})
